package com.anche.cywebnew.Service.configManager.impl;

import com.anche.cywebnew.DAO.configManager.SysCodeMapper;
import com.anche.cywebnew.Pojo.configManager.CySysCode;
import com.anche.cywebnew.Pojo.configManager.SysOptions;
import com.anche.cywebnew.Service.configManager.SysCodeService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class SysCodeServiceImpl implements SysCodeService {

    @Autowired
    private SysCodeMapper sysCodeMapper;

    @Override
    public Page<CySysCode> getSysCodePager(Integer page, Integer limit, CySysCode cySysCode) {
        Page<CySysCode> page1 = PageHelper.startPage(page, limit);
        sysCodeMapper.selectSysCodeList(cySysCode);
        return page1;
    }

    @Override
    public List<CySysCode> getSysCodeList(CySysCode cySysCode) {
        return sysCodeMapper.selectSysCodeList(cySysCode);
    }

    @Override
    public void addSysCode(CySysCode cySysCode) {
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        cySysCode.setId(uuid);
        sysCodeMapper.insertSysCode(cySysCode);
    }

    @Override
    public void setSysCode(CySysCode cySysCode) {
        sysCodeMapper.updateById(cySysCode);
    }

    @Override
    public void delSysCode(String id) {
        sysCodeMapper.deleteById(id);
    }

    @Override
    public List<String> getOiNameList() {
        return sysCodeMapper.selectDistinctOiName();
    }
}
